<?php
require('Base.php');
class FpmStatus extends Base
{

}
/* ============================= CLASS FINISHED  ============================= */

	// 登录验证
	session_start();
	if(!isset($_SESSION['user']) || !$_SESSION['user'])
	{
		header('Location: ./login.html');
	}

	$FpmStatus = new FpmStatus();
	$res = $FpmStatus->api_res;

	// 获取FPM版本
	$fpm_ver = (int)trim($_GET['fpm_ver']);
	// 获取对应版本的监听接口，并获取全量信息
	$listener = "listener_{$fpm_ver}";
	$url = $FpmStatus->config['fpm'][$listener] . '?full&json';
	$get_pool_info = $FpmStatus->curlRequest($url, 'get');
	if($get_pool_info['status'] != 1)
	{
		$err_msg = $get_pool_info['err_msg'];
		$http_code = $get_pool_info['http_code'];
		$res['err_msg'] = "{$err_msg} (HTTP Code: {$http_code})";
		echo json_encode($res, JSON_UNESCAPED_UNICODE);
	}
	$pool_info = json_decode($get_pool_info['data'], true);
	if(!$pool_info)
	{
		$res['err_msg'] = json_last_error_msg();
		echo json_encode($res, JSON_UNESCAPED_UNICODE);
	}

	$res['status'] = 1;
	$res['data'] = $pool_info;
	echo json_encode($res, JSON_UNESCAPED_UNICODE);

?>
